package ReadWriteFieldsRelations;


import java.io.IOException;
import java.lang.reflect.Method;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import random.TestClusterBuilder;
import util.GAConfig;


public class MethodDependences {


	  public static void main(String[] args)throws ClassNotFoundException {
			System.out.println("CUT is:" + GAConfig.classFilePath);
			 Set<Class<?>> allClasses = new LinkedHashSet<Class<?>>();
		      //get class from file
		      allClasses.addAll(TestClusterBuilder.readClassFromFile());

		      System.out.println("There are " + allClasses.size() + " classes as input");
		      
		      System.out.println(allClasses);
		      Set<Class<?>> classesToTest = TestClusterBuilder.filterUntestableClasses(allClasses);
		    MethodRelations relations = new MethodRelations(classesToTest);
		    try {		    	
		    		relations.buildRelations();
				    System.out.println(relations.showFieldReadWrites());
				    System.out.println(relations.showDependence());
				    relations.buildWriteFiledMethodDependence();
	//			    relations.buildMethodsCallPrivate(mName);
//				    System.out.println(relations.showFieldReadWrites());
				    Map<Method, ReadWriteMethods> methodsReadFields=  new LinkedHashMap<Method, ReadWriteMethods>();
//				    for(int i=0;i<list.size();i++)
//				    	methodsReadFields= relations.getMethodsReadFileds(list.get(i).getName().toString());
				    System.out.println();
		    } catch (IOException e) {
		    		throw new RuntimeException(e);
		    }

		  }
}
